import { ListView, View, Text, Image } from "@tarojs/components";
import {  useEffect } from "react";
import {  useState } from "react";
import request from "@/utils/request.js";
// import CustomNavBar from "@/component/CustomNavBar";
import './issues.scss'
import next_img from '@/static/images/auth/next.png'
import Taro, { useReady } from "@tarojs/taro";



definePageConfig({
  navigationBarTitleText: '遇到问题'
})

export default function Issues() {
  const [list, setList] = useState([])
  useReady(() => {
    request({ url: 'api/auth/issues/list' }).then(res => {
      setList(res.data)
    })
    
  })
  const nav = (issueName, issueAnswer) => {
    Taro.navigateTo({
      url: `/login/privacy/issuesDetail?issueName=${issueName}&issueAnswer=${issueAnswer}`,
      // url: `/pages/auth/privacy/issuesDetail`,
    })

  }
  const renderItem = (item, index) => (
    <View key={index} className="list-item">
      <Text>  {item.issueName}</Text>
      <Image className='icon_global' mode='widthFix' src={next_img} onClick={() => { nav(item.issueName, item.issueAnswer) }}></Image>
    </View>
  )

  return (
    <View>
      {/* <CustomNavBar title='遇到问题'></CustomNavBar> */}
      <ListView
        style={{ height: '100vh' }}
      >
        {list.map((item, index) => renderItem(item, index))}
      </ListView>
    </View>
  )


}